{include file="public/header" /}
<body class="gray-bg">
<div class=" animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>管理员列表</h5>
        </div>
        <div class="ibox-content">
            <div class="row row-lg">
                <div class="col-sm-12">
                    <!--搜索框开始-->
                    <form id='commentForm'  method="post" class="form-inline">
                            <div class="form-group">
                                <input type="text" class="form-control" placeholder="管理员名称" id="username" name="user_name">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control" placeholder="商户名称" id="name" name="name">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control" id="mch_account" placeholder="商户账号" name="mch_account">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control" id="mobile" placeholder="手机号" name="mobile">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control" id="email" placeholder="邮箱" name="mobile">
                            </div>
                            <div class="form-group">
                                <button class="btn btn-primary" type="button" style="margin-top:5px" id="search"><strong>搜 索</strong>
                                </button>
                            </div>
                    </form>
                    <!--搜索框结束-->
                    <div class="btn-group-sm" id="toolbar">
                        <button class="btn btn-default btn-outline" type="button" name="refresh" aria-label="refresh" title="刷新">
                            <i class="glyphicon glyphicon-repeat"></i>
                        </button>

                        <button type="button" id="add" class="btn btn-primary button-margin" onclick="CodeGoods.add()">
                            <i class="fa fa-plus"></i>&nbsp;添加
                        </button>

                        <button type="button" id="edit" class="btn btn-danger button-margin" onclick="CodeGoods.add()">
                            <i class="fa fa-edit"></i>&nbsp;编辑
                        </button>

                        <button type="button" id="del" class="btn btn-danger button-margin" onclick="CodeGoods.add()">
                            <i class="fa fa-trash"></i>&nbsp;删除
                        </button>
                    </div>
                    <table id="cusTable">
                    </table>
                </div>
            </div>
        </div>
    </div>
    <!-- End Panel Other -->
    {include file="public/footer" /}
    <script type="text/javascript">
        function initTable() {
            //先销毁表格
            $('#cusTable').bootstrapTable('destroy');
            //初始化表格,动态从服务器加载数据
            $("#cusTable").bootstrapTable({
                method: "get",  //使用get请求到服务器获取数据
                url: "{:url('admin/index')}", //获取数据的地址
                striped: true,  //表格显示条纹
                toolbar: '#toolbar',              //工具按钮用哪个容器
                toolbarAlign:'left',
                showColumns: true,                  //是否显示所有的列（选择显示的列）
                showRefresh: true,                  //是否显示刷新按钮
                clickToSelect: true,                //是否启用点击选中行
                showToggle: true,                   //是否显示详细视图和列表视图的切换按钮
                cardView: false,                    //是否显示详细视图
                exportTypes: ['csv', 'txt', 'xml'],
                silent: true,
                strictSearch: true,
                pagination: true, //启动分页
                pageSize: 10,  //每页显示的记录数
                pageNumber:1, //当前第几页
                pageList: [5, 10, 15, 20, 25],  //记录数可选列表
                sidePagination: "server", //表示服务端请求
                paginationFirstText: "首页",
                paginationPreText: "上一页",
                paginationNextText: "下一页",
                paginationLastText: "尾页",
                queryParamsType : "undefined",
                columns:[[
                    {checkbox: true,fixed: true},
                    {field:'id',title:'主键'},
                    {field:'user_name',title:'管理员名称'},
                    {field:'nick_name',title:'昵称'},
                    {field:'email',title:'邮箱'},
                    {field:'login_times',title:'登录次数'},
                    {field:'last_login_ip',title:'上次登录ip'},
                    {field:'last_login_time',title:'上次登录时间'},
                    {field:'status',title:'状态',formatter:function (value) {
                        if(value=='1'){
                            return '<span class="text-navy"><i class="fa fa-circle"></i> 启用</span>';
                        }else if (value=='2'){
                            return '<span class="text-danger"><i class="fa fa-circle"></i> 禁用</span>';
                        }
                    }},
                    {field:'operate',title:'操作'}
                ]],
                queryParams: function queryParams(params) {   //设置查询参数
                    var param = {
                        pageNumber: params.pageNumber,
                        pageSize: params.pageSize,
                        searchText:$('#title').val()
                    };
                    return param;
                },
                onLoadSuccess: function(res){  //加载成功时执行
                    if(1== res.code){
                        window.location.reload();
                    }
                    layer.load(0, {shade: false,time:1000});
                },
                onLoadError: function(){  //加载失败时执行
                    layer.msg("加载数据失败");
                }
            });
        }

        $(document).ready(function () {
            //调用函数，初始化表格
            initTable();
            $("td,th").addClass("text-center");
            //当点击查询按钮的时候执行
            $("#search").bind("click", initTable);

        });
    </script>
</body>
</html>
